#pragma once
#include <typescommon.h>

struct stateMachineBaseInform;
struct stateMachineManagerInform;
typedef int (*stateMachineInit)(struct stateMachineBaseInform *thisState);
typedef int (*stateMachineRun)(struct stateMachineBaseInform *thisState);
typedef int (*stateMachineQuit)(struct stateMachineBaseInform *thisState);
struct stateMachineBaseInform
{
    stateMachineInit stateInit;
    stateMachineRun stateRun;
    stateMachineQuit stateQuit;
    int stateId;
    struct stateMachineManagerInform *stateManager;
};
#define stateMachineInvalidID (-1)

#define stateMachineBaseDeine(setinit, setrun, setquit, setid, setManager) \
    {                                                                      \
        setinit, setrun, setquit, setid, setManager                        \
    }

struct stateMachineManagerInform
{
    struct stateMachineBaseInform *statelist;
    void *stateContext;
    int stateSize;
    int stateIdNow;
    int stateIdNext;
};

int stateMachineManagerInit(struct stateMachineManagerInform *smnger, void *setContext, struct stateMachineBaseInform *setStateBuffer,
                            int setStateSize, int initState);
int stateMachineManagerRun(struct stateMachineManagerInform *smnger);
int stateMachineManagerQuit(struct stateMachineManagerInform *smnger);
int stateMachineManagerTransition(struct stateMachineManagerInform *smnger, int nextStateId);
